package com.hanhai.zrb.api.biz.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;
import com.hanhai.zrb.api.biz.dao.mybatis.UserStatisticDetailMapper;
import com.hanhai.zrb.api.biz.service.UserService;
import com.hanhai.zrb.api.biz.service.UserStatisticService;
import com.hanhai.zrb.model.user.UserStatisticDetail;
import com.hanhai.zrb.model.user.dto.UserSearchDto;
import com.hanhai.zrb.model.user.dto.UserStatisticDetailDto;

@Service("userStatisticService")
public class UserStatisticServiceImp implements UserStatisticService {

	@Resource
	private UserStatisticDetailMapper userStatisticDetailMapper;
	@Resource
	private UserService userService;
	@Override
	public PageInfo queryAttentionUser(Long id,
			Integer page, Integer rows) {
		//根据FundId查询所有userId
		UserStatisticDetailDto userStatisticDetailDto = new UserStatisticDetailDto();
		userStatisticDetailDto.setDestId(id);
		List<UserStatisticDetail> userStaticlist = userStatisticDetailMapper.queryByCondition(userStatisticDetailDto);
		UserSearchDto dtoUser = new UserSearchDto();
		PageInfo pageInfo = null;
		if(CollectionUtils.isNotEmpty(userStaticlist)){
			List<Long> uids = new ArrayList<Long>();
			for (UserStatisticDetail userStatisticDetail:userStaticlist) {
				uids.add(userStatisticDetail.getUserId());
			}
			if(CollectionUtils.isNotEmpty(uids)){
				dtoUser.setUids(uids);
			}
			pageInfo =userService.queryUserBySearchDto(dtoUser, page, rows);
		}
        

		return pageInfo;
	}

}
